<?php

namespace App\Http\Controllers\home;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;

class Common extends Controller
{
    //
    public function __construct(Request $request)
    {
        $cates = DB::table('article_cate')->lists();
        //查询网站设置
        $setting = DB::table('setting')->where('names','site_setting')->item();
        if($setting){
            $setting['vals'] = json_decode($setting['vals'],true);
        }
        $aid = (int)$request->id;
        //获取热门文章
        $re = DB::table('article')->where('cid',$aid)->orderBy('pv','desc')->lists();
        $logo = DB::table('setting')->where('names','site_logo')->item();
        if($logo){
            $logo['vals'] = json_decode($logo['vals'],true);
        }

        view()->share('setting',$setting);
        view()->share('logo',$logo);
        view()->share('cates',$cates);
        view()->share('re',$re);

    }
}
